package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.AttendanceDateSettings;
import com.group.project.hrms.mapper.AttendanceDateSettingsMapper;
import com.group.project.hrms.service.IAttendanceDateSettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class AttendanceDateSettingsService implements IAttendanceDateSettingsService {

    @Autowired
    private AttendanceDateSettingsMapper attendanceDateSettingsMapper;

    @Override
    public int insertAttendanceDateSettings(AttendanceDateSettings attendanceDateSettings) {
        return attendanceDateSettingsMapper.insert(attendanceDateSettings);
    }

    @Override
    public int deleteAttendanceDateSettings(AttendanceDateSettings attendanceDateSettings) {
        return attendanceDateSettingsMapper.deleteByPrimaryKey(attendanceDateSettings);
    }

    @Override
    public int updateAttendanceDateSettings(AttendanceDateSettings attendanceDateSettings) {
        return attendanceDateSettingsMapper.updateByPrimaryKey(attendanceDateSettings);
    }

    @Override
    public AttendanceDateSettings selectOneAttendanceDateSettings(AttendanceDateSettings attendanceDateSettings) {
        return attendanceDateSettingsMapper.selectByPrimaryKey(attendanceDateSettings);
    }

    @Override
    public AttendanceDateSettings selectAttendanceDateSettingsBySettingsID(String settingsID) {
        Example example = new Example(AttendanceDateSettings.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orEqualTo("attendanceDateId" , settingsID);
        return attendanceDateSettingsMapper.selectOneByExample(example);
    }

    @Override
    public List<AttendanceDateSettings> selectAllAttendanceDateSettings() {
        return attendanceDateSettingsMapper.selectAll();
    }
}
